#include <iostream>

#include <fstream>

#include <ctime>



using namespace std;



int main()

{

    const int LEN = 5000;

    bool f = true;

    int a1[LEN], a2[LEN], a3[LEN];

    ifstream file ("m1_sorted.txt");

    for(int i = 0; i < 5000; i++) file >> a1[i];

    file.close();

    int i = 0;

    int c = 0;

    unsigned int t_start = clock();

    while (f){

        f = false;

        for (int j = 0; j < 5000 - i - 1; i++){

            if (a1[j]>a1[j+1]){

                c=a1[j];

                a1[j]=a1[j+1];

                a1[j+1]=c;

                f = true;

            }

        }

        ++i;

    }

    unsigned int t_finish = clock();

    unsigned int t_work = t_finish - t_start;

    cout<<"m1_sorted " << t_work << " milliseconds \n";

    ifstream file2 ("m2_sorted.txt");

    for(int i = 0; i < 5000; i++) file2 >> a2[i];

    file2.close();

    int k = 0;

    int q = 0;

    bool ff = true;

    unsigned int t2 = clock();

    while (ff){

        ff = false;

        for (int j = 0; j < 5000 - i - 1; i++){

            if (a2[j]>a2[j+1]){

                q=a2[j];

                a2[j]=a2[j+1];

                a2[j+1]=q;

                ff = true;

            }

        }

        ++k;

    }

    unsigned int t2f = clock();

    unsigned int t2w = t2f - t2;

    cout<<"m2_sorted " << t2w << " milliseconds \n";

    ifstream file3 ("m3_sorted.txt");

    for(int i = 0; i < 5000; i++) file3 >> a3[i];

    file3.close();

    int r = 0;

    int z = 0;

    bool fff = true;

    unsigned int t3 = clock();

    while (fff){

        fff = false;

        for (int j = 0; j < 5000 - i - 1; i++){

            if (a2[j]>a2[j+1]){

                z=a2[j];

                a2[j]=a2[j+1];

                a2[j+1]=z;

                fff = true;

            }

        }

        ++r;

    }

    unsigned int t3f = clock();

    unsigned int t3w = t3f - t3;

    cout<<"m3_sorted " << t3w << " milliseconds \n";
}
